<?php

/**
 * Created by Shijie Liu. 2017/6/18
 *  通用数据库处理工具
 */
class DB_util
{
    /**
     * @param $sql
     * @return bool|mysqli_result
     * mysqli_result 查询错误返回false，查询为空和有数据均为数组，可通过行数查询是否为空
     */
    function queryDB($sql){

        $con_db = mysqli_connect("localhost","root","19971010","book_store");

        if (empty($con_db)){
            die("数据库连接错误!".mysqli_error($con_db));
        }else{
            $result = mysqli_query($con_db,$sql);
        }
        $con_db->close();
        return $result;
    }

    function multi_queryDB($sql1,$sql2){

        $con_db = mysqli_connect("localhost","root","19971010","book_store");

        if (empty($con_db)){
            die("数据库连接错误!".mysqli_error($con_db));
        }else{
            $result = mysqli_query($con_db,$sql1.$sql2);
        }
        $con_db->close();
        return $result;
    }


}